import facade
from xjlibrary.our_file_dir import BaseDir

curpath = BaseDir.get_file_dir_absolute(__file__)
TopPath = BaseDir.get_upper_dir(curpath, -2)
configfile = BaseDir.get_new_path(curpath, "db.ini")

logger = facade.get_streamlogger()
mysqlutils = facade.MysqlUtiles(configfile, "db", logger=logger)


Lists = []
Lists1 = []
# for file in BaseDir.get_dir_all_files(r"\\192.168.30.177\样例数据\gitbotubook"):
#     filename = file.split("\\")[-1]
#     if filename.find("jpg") > -1:
#         rawid = filename.split(".")[0]
#         Lists.append(rawid)

for line in BaseDir.read_file_r_mode_yield("./rawid.txt"):
    Lists.append(line.strip())


sql = "select rawid from article where stat=1"
rows = mysqlutils.SelectFromDB(sql)
for row in rows:
    Lists1.append(row[0])
# print(len(set(Lists1)))
# print(len(set(Lists)))
Lists3 = set(Lists1)-set(Lists)
print(Lists3)

# BaseDir.single_write_file(str(tuple(Lists1)), "./rawid2.txt")
# with open("./rawid2.txt", 'w', encoding="utf-8") as f:
#     for i in Lists1:
#         f.write(i+"\n")


